import { ltrim } from '@/utils/index'
import request from '@/utils/request'

export function getToken() {
  return request({
    url: '/qiniu/upload/token', // 假地址 自行替换
    method: 'get'
  })
}

export function uploadFile(data, filetype = '') {
  if (filetype) {
    filetype = '-' + ltrim(filetype, '-')
  }
  return request({
    url: `/attachs/upload${filetype}`,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    timeout: process.env.VUE_APP_REQUEST_DOWNLOAD_TIMEOUT
  })
}

export function ossStsAuthent() {
  return request({
    url: '/attachs/authent',
    method: 'post'
  })
}
